package com.xxwy.lintcodes;

import com.xxwy.Twopoints;

/**
 * @author xxwy
 * 字符大小写排序
 * sort letters by case
 * 给出"abAcD"，一个可能的答案为"acbAD"
 */
@Twopoints
public class Num49 {

    public void sortLetters(char[] chars) {
        // write your code here
        if (chars == null || chars.length == 0) {
            return;
        }
        int l = 0;
        int r = chars.length - 1;
        while (l < r) {
            while (l < r && chars[l] <='z' && chars[l]>='a'){
                l++;
            }
            while (l<r&& chars[r] >='A' && chars[r] <='Z'){
                r--;
            }
            if(l>r){break;}
            char temp = chars[l];
            chars[l] = chars[r];
            chars[r] = temp;
            l++;
            r--;
        }
        System.out.println("xxx");
    }

    public static void main(String[] args) {
        char[] chars = {'a', 'b', 'Z', 'x', 'T'};
        new Num49().sortLetters(chars);
    }
}
